using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using T2.Logging.ASPMVC.Entity.Interface;
using T2.Logging.ASPMVC.Entity;
using T2.Logging.Business.Entities;
using T2.Logging.Business.Entities.Interfaces;
using T2.Logging.ASPMVC.Entity.Search;
using T2.Logging.ASPMVC.Entity.Search.Interface;
using T2.Logging.Business.Entities.Search;
using T2.Logging.Business.Entities.Search.Interfaces;
using T2.Logging.ASPMVC.Entity.Translators;
using T2.Logging.ASPMVC.Entity.Translators.Search;


namespace T2.Logging.ASPMVC.ViewModel
{

	public class PasswordQuestionViewModel
	{
		Business.BusinessService bs = new Business.BusinessService();
		public PasswordQuestionViewModel(bool loadParent)
		{
		if (loadParent)
			{
			}
		}
		
		private String m_header;
		public String Header
        {
            get
            {
                return "Password Question";
            }
			
			set
            {
                m_header = value;
            }
        }
		
		private String m_title;
		public String Title
        {
            get
            {
                return "Password Question";
            }
			
			set
            {
                m_title = value;
            }
        }
		
		private IPasswordQuestion_ui m_model;
		public IPasswordQuestion_ui Model
		{
			get
			{
				return m_model;
			}
			set
			{
				m_model = value;
			}
		}
				
        
		
		public void LoadModel(IPasswordQuestion_ui param)
        {
            PasswordQuestionUITranslator trans = new PasswordQuestionUITranslator();
            IPasswordQuestion_biz bizParam = trans.TranslateToBusinessLayer(param);
            List<IPasswordQuestion_biz> tempRetVal = bs.PasswordQuestionController_Get(bizParam, true, true);
            IPasswordQuestion_ui retVal = new PasswordQuestion_ui();
            if (tempRetVal != null && tempRetVal.Count > 0)
            {
                retVal = trans.TranslateFromBusinessLayer(tempRetVal.First());
            }

            m_model = retVal;

        }

        public Int32 Set(IPasswordQuestion_ui param)
        {
            PasswordQuestionUITranslator trans = new PasswordQuestionUITranslator();
            IPasswordQuestion_biz bizParam = trans.TranslateToBusinessLayer(param);
            IDictionary<string,int> r = bs.PasswordQuestionController_Set(bizParam);
            var ret = r.ToList().Select(s => new { Key = s.Key, Value = s.Value });
            Int32 retVal = ret.Where(z => z.Key == "Return_Value").Select(m => m.Value).FirstOrDefault();
			return retVal;
        }

       

        public List<IPasswordQuestion_ui> SearchList(IPasswordQuestionSearch_ui param)
        {
            PasswordQuestionUISearchTranslator transSearch = new PasswordQuestionUISearchTranslator();
            IPasswordQuestionSearch_biz bizParam = transSearch.TranslateToBusinessLayer(param);
            List<IPasswordQuestion_biz> retValBiz = bs.PasswordQuestionController_Search(bizParam, true, true);
            List<IPasswordQuestion_ui> retVal = new List<IPasswordQuestion_ui>();
            PasswordQuestionUITranslator trans = new PasswordQuestionUITranslator();
            foreach (IPasswordQuestion_biz item in retValBiz)
            {
                IPasswordQuestion_ui temp = trans.TranslateFromBusinessLayer(item);
                retVal.Add(temp);
            }

            
            return retVal;

        }

        

        public List<IPasswordQuestion_ui> ModelList(IPasswordQuestion_ui param)
        {

            PasswordQuestionUITranslator trans = new PasswordQuestionUITranslator();
            IPasswordQuestion_biz bizParam = trans.TranslateToBusinessLayer(param);
            List<IPasswordQuestion_biz> retValBiz = bs.PasswordQuestionController_Get(bizParam, true, true);
            List<IPasswordQuestion_ui> retVal = new List<IPasswordQuestion_ui>();
            foreach (IPasswordQuestion_biz item in retValBiz)
            {
                IPasswordQuestion_ui temp = trans.TranslateFromBusinessLayer(item);
                retVal.Add(temp);
            }

            
            return retVal;

        }
		
	}
}
